//
//  SISSLabelTextView.m
//  SISSAPP
//
//  Created by 优房网 on 2017/8/2.
//  Copyright © 2017年 优房网. All rights reserved.
//

#import "SISSLabelTextView.h"


@implementation SISSLabelTextView

- (instancetype)initWithFrame:(CGRect)frame {
    
    if (self = [super initWithFrame:frame]) {
        
        [self initUI];
        [self initConstraint];
    }
    
    return self;
}

- (void)setPlaceholder:(NSString *)placeholder {
    _placeholder = placeholder;
    
    self.textView.placeholder = placeholder;
}

#pragma mark - UI
- (void)initUI {
    
    UILabel *label = [[UILabel alloc] init];
    label.numberOfLines = 0;
    label.textColor = MAIN_TEXT_COLOR;
    label.font = [UIFont systemFontOfSize:16];
    [self addSubview:label];
    self.label = label;
    
    SISSTextView *textView = [[SISSTextView alloc] init];
    textView.layer.borderWidth = 1;
    textView.layer.borderColor = [UIColor groupTableViewBackgroundColor].CGColor;
    textView.textColor = MAIN_TEXT_COLOR;
    textView.font = [UIFont systemFontOfSize:16];
    [self addSubview:textView];
    self.textView = textView;
}

#pragma mark - 约束
- (void)initConstraint {
    
    WeakSelf
    CGFloat margin = 8.0;
    CGFloat textViewHeight = 88.0;
    [self.label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.equalTo(weakSelf);
    }];
    
    [self.textView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(weakSelf);
        make.top.equalTo(weakSelf.label.mas_bottom).offset(2 * margin);
        make.height.mas_equalTo(textViewHeight);
        make.bottom.equalTo(weakSelf);
    }];
}

@end
